# ์ „์—ญ ๊ฐ์ฒด window ๐Ÿ”—

# ์ „์—ญ ๊ฐ์ฒด window

๋ธŒ๋ผ์šฐ์ € ์š”์†Œ๋“ค, ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์—”์ง„(์—”์ง„ ์ •๋ณด๋ฅผ ๋‹ด๊ณ ์žˆ๋Š” ๊ฒƒ์œผ๋กœ ์ถ”์ •) ๋“ฑ ๋ชจ๋“  ๋ณ€์ˆ˜๋ฅผ ๋‹ด๊ณ  ์žˆ๋Š” ๊ฐ์ฒด

# TODO window ๊ฐ์ฒด์˜ ์ž๋ฐ”์Šคํฌ๋ฆฝํŠธ ์—”์ง„

# BOM

# DOM

getElementById(), getElementByClassName(), getElementByName(), getElementByTagName()

querySelector(css ์„ ํƒ์ž๋กœ) querySelctorAll(Css์„ ํƒ์ž, ํƒœ๊ทธ๋ช…[์†์„ฑ๋ช…=์†์„ฑ๊ฐ’], ๋ถ€๋ชจ>์ž์‹, ๋ถ€๋ชจ์ž์†)

createElement(ํƒœ๊ทธ๋ช…), createTextNode(ํ…์ŠคํŠธ)

createDocumentFragment() ๊ฐ€์งœ document

  • JS๋กœ DOM ํƒœ๊ทธ๋ฅผ ์กฐ์ž‘ํ•˜๋ฉด ์„ฑ๋Šฅ์ด ๋‚ฎ์•„์ง€๊ธฐ ๋•Œ๋ฌธ์— ์‚ฌ์šฉํ•œ๋‹ค
  • ์—ฌ๋Ÿฌ ํƒœ๊ทธ๋ฅผ ๋ฐ˜๋ชฉ๋ฌธ์„ ์‚ฌ์šฉํ•ด ๋™์‹œ์— ์ถ”๊ฐ€ํ•˜๋Š” ๋ฐฉ๋ฒ•. body ์— ๋‹จ ํ•œ๋ฒˆ ์˜ํ–ฅ์„ ์ฃผ๋Š”๋ฐฉ๋ฒ•

# Node

ํƒœ๊ทธ๋…ธ๋“œ + ํ…์ŠคํŠธ ๋…ธ๋“œ

firstChild, lastChild, parentNode, previousSibling, nextSibling

# Element

ํƒœ๊ทธ ๋…ธ๋“œ

firstElementChild, lastlementChild, parentElement previousElementSibling, nextElementSibling

# ํƒœ๊ทธ. innerHTML, outerHTML

ํƒœ๊ทธ.innerHTML

  • ์„ ํƒ ํƒœ๊ทธ์˜ ๋‚ด์šฉ๋ฌผ์„ ์–ป์–ด์˜ค๊ฑฐ๋‚˜ ๋ณ€๊ฒฝ (์„ ํƒํƒœ๊ทธ ๋นผ๊ณ  ๋‚ด์šฉ๋ฌผ๋งŒ)

ํƒœ๊ทธ.outerHTML

  • ํ˜„์žฌ ํƒœ๊ทธ์˜ ๋‚ด์šฉ๋ฌผ์„ ์–ป์–ด์˜ค๊ฑฐ๋‚˜ ๋ณ€๊ฒฝ (์„ ํƒ ํƒœ๊ทธ ํฌํ•จ ๋‚ด์šฉ๋ฌผ)

# ํƒœ๊ทธ.์†์„ฑ

  • id, className, name, value, placeholder, checked, diasbled, readonly
  • attributes(ํ•ด๋‹น ํƒœ๊ทธ์˜ ๋ชจ๋“  ์†์„ฑ)
  • clientHeight, clientWidth (ํƒœ๊ทธ์˜ margin, border, scollerbar ๋ฅผ ์ œ์™ธํ•œ ๋†’์ด์™€ ๋„ˆ๋น„)
  • scrollHeight, scrollerWidth (์Šคํฌ๋กค ๊ฐ€๋Šฅํ•œ ๋ฒ”์œ„๊นŒ์ง€ ํฌํ•จํ•œ ํƒœ๊ทธ ๋†’์ด, ๋„ˆ๋น„)
  • offsetHeight, offsetWidth (ํƒœ๊ทธ์˜ margin๋งŒ ์ œ์™ธํ•œ ๋†’์ด ๋„ˆ๋น„)

# ํƒœ๊ทธ.๋ฉ”์„œ๋“œ

  • appendChild, removeChild, insertBefore (์ž์‹ ์˜ ํ˜•์ œํƒœ๊ทธ ์•ž์— ์‚ฝ์ž…), cloneNode(์ž์‹ ๋ณต์‚ฌ)
  • document.body.childNodes[document.body.childNodes.length - 1 ]

# Date

new Date(), new Date(1997, 02, 03) getFullYear, setFullYear, getMonth, setMonth, getDate, setDate, getDay, setDay, getHour, setHour, getMinutes, setMinutes, getSeconds, setSeconds, toString(ํ˜„์žฌ๋‚ ์งœ), toLocaleString(๋ณด๊ธฐ์ข‹์€๋‚ ์งœ), toUTCString(์„ธ๊ณ„์‹œ)

#

getElementById๊ฐ€ queryselector์— ๋น„ํ•ด ์ƒ๋Œ€์ ์œผ๋กœ ๋น ๋ฅด๊ธฐ๋Š” ํ•˜๋‚˜, ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํ•จ์ˆ˜์˜ ํšŸ์ˆ˜ querySelector์˜ ์„ฑ๋Šฅ(๋Œ€๋žต ์ดˆ๋‹น 700๋งŒ๊ฑด ์ž‘์—…์ฒ˜๋ฆฌ ๊ฐ€๋Šฅํ•˜๋‹ค๋„ค์š”)๊ณผ ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ์„ ๊ณ ๋ คํ•ด๋ดค์„ ๋•Œ ์„ž์–ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ ๋ณด๋‹ค ํ†ต์ผํ•˜๋Š” ๊ฒƒ์ด ๋‚ซ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค! https://hashcode.co.kr/questions/5692/%EA%B0%95%EC%9D%98-4-11-queryselector%EC%97%90-%EC%84%B1%EB%8A%A5%EB%AC%B8%EC%A0%9C%EC%97%90-%EB%8C%80%ED%95%B4-%EC%A7%88%EB%AC%B8-%EB%93%9C%EB%A6%BD%EB%8B%88%EB%8B%A4getElementById๊ฐ€ queryselector์— ๋น„ํ•ด ์ƒ๋Œ€์ ์œผ๋กœ ๋น ๋ฅด๊ธฐ๋Š” ํ•˜๋‚˜, ํ”„๋กœ์ ํŠธ ๋‚ด์—์„œ ์‚ฌ์šฉํ•˜๋Š” ํ•จ์ˆ˜์˜ ํšŸ์ˆ˜ querySelector์˜ ์„ฑ๋Šฅ(๋Œ€๋žต ์ดˆ๋‹น 700๋งŒ๊ฑด ์ž‘์—…์ฒ˜๋ฆฌ ๊ฐ€๋Šฅํ•˜๋‹ค๋„ค์š”)๊ณผ ์ฝ”๋“œ์˜ ๊ฐ€๋…์„ฑ์„ ๊ณ ๋ คํ•ด๋ดค์„ ๋•Œ ์„ž์–ด์„œ ์‚ฌ์šฉํ•˜๋Š” ๊ฒƒ ๋ณด๋‹ค ํ†ต์ผํ•˜๋Š” ๊ฒƒ์ด ๋‚ซ๋‹ค๊ณ  ์ƒ๊ฐํ–ˆ์Šต๋‹ˆ๋‹ค! https://hashcode.co.kr/questions/5692/%EA%B0%95%EC%9D%98-4-11-queryselector%EC%97%90-%EC%84%B1%EB%8A%A5%EB%AC%B8%EC%A0%9C%EC%97%90-%EB%8C%80%ED%95%B4-%EC%A7%88%EB%AC%B8-%EB%93%9C%EB%A6%BD%EB%8B%88%EB%8B%A4 https://github.com/next-step/js-todo-list-step2/pull/18/files#r492672380